package com.fuint.module.backendApi.controller;

import com.fuint.common.dto.ExamDataDTO2;
import com.fuint.common.service.ExamReceiveService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

@Api(tags="体检数据对接")
@RestController
@AllArgsConstructor
@RequestMapping(value = "/v1")
public class ExamReceiveController {
    @Autowired
    private ExamReceiveService examReceiveService;

    @ApiOperation(value = "体检数据对接")
    @RequestMapping(value = "/receive", method = RequestMethod.POST)
    @CrossOrigin
    public ResponseEntity<Map<String, Object>> receiveExamData(@RequestBody ExamDataDTO2 dto) {Map<String, Object> response = new HashMap<>();
        try {
            examReceiveService.saveExamData(dto);
            response.put("success", true);
            response.put("message", null);
        } catch (Exception e) {
            response.put("success", false);
            response.put("message", e.getMessage());
        }
        return ResponseEntity.ok(response);
    }
}
